/*
 * litchicms litchi.js
 * Copyright (C) 2010-5-11 Author: tiefa(539247@qq.com)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
function $(string){
    $temp=document.getElementById(string);
    if($temp){
        $temp.$$=function(s){
            return window.$$(this,s);
        }
    }
    return $temp;
}
function $$(element,TagName){
    if(arguments.length==2){
        if(typeof element=='object'){
            return element.getElementsByTagName(TagName);
        }else{
            return $(element).getElementsByTagName(TagName);
        }
    }
    return document.getElementsByTagName(element);
}

function getBrowserInfo(){
    Browser={};
    if (document.compatMode == "BackCompat") {
        Browser.cWidth = document.body.clientWidth;
        Browser.cHeight = document.body.clientHeight;
    }
    else { //document.compatMode == "CSS1Compat"
        Browser.cWidth = document.documentElement.clientWidth;
        Browser.cHeight = document.documentElement.clientHeight;
    }
    
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? Browser.ie = s[1] : 	(s = ua.match(/firefox\/([\d.]+)/)) ? Browser.firefox = s[1] :	(s = ua.match(/chrome\/([\d.]+)/)) ? Browser.chrome = s[1] :	(s = ua.match(/opera.([\d.]+)/)) ? Browser.opera = s[1] :	(s = ua.match(/version\/([\d.]+).*safari/)) ? Browser.safari = s[1] : 0;
	
}

function fixedfooter(){
    getBrowserInfo();

    $('footer').style.top=(Browser.cHeight-$('footer').clientHeight)+'px';
}
function initfooter(){
    fixedfooter();
    DIV=document.createElement('DIV');
    DIV.style.height=$('footer').clientHeight+30+'px';
    DIV.style.width="100%";
    $('wrapper').appendChild(DIV);
    if(!Browser.ie || Browser.ie!=6){
        $('footer').style.left="0px";
    }
    if(Browser.ie && (Browser.ie==6 || Browser.ie==7)){
        $('footer').innerHTML+="&nbsp;&nbsp;&nbsp;您正在使用兼容性差的低版本浏览器,建议您升级,或者使用<a href=\"http://www.google.com/chrome\" target='_blank' style=\"color:#F00\">Chrome</a>浏览器";
    }
}

function changepanelONOFF(){
    var ev=window.event || arguments.callee.caller.arguments[0]; 
    var target= ev.target||ev.srcElement;
    if(target.parentNode.style.height=='auto' || target.parentNode.style.height==''){
        target.parentNode.style.height="26px";
        if(Browser.ie && Browser.ie==6){
            target.parentNode.style.height="37px";
        }
    }else{
        target.parentNode.style.height="auto";
    }
}

function autorun(){
    for(var i =0 ; i <AUTORUN.length ; i++){
        AUTORUN[i].call(window);
    }
}

AUTORUN=new Array();
window.onload=function(){
    getBrowserInfo();
    //initfooter();
    //autorun();
    }
window.onresize=function(){
    //fixedfooter();
}












//一些功能函数

//隐藏某一个 显示另外一个
function showthishidethat(str1,str2,display){
    if(!display)display="";
    $(str1).style.display=display;
    $(str2).style.display='none';
}

//取得nextSibling
function nextSibling(element){
    if(Browser.ie){
        return element.nextSibling;
    }else{
        for(var i=0;;i++){
            if(element.nextSibling.nodeType==1){
                return element.nextSibling;
            }
            element=element.nextSibling;
        }
    }
}